package com.wss.service.impl;

import com.wss.dao.LoginDao;
import com.wss.domain.Account;
import com.wss.service.LoginService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("loginService")
public class LoginServiceImpl implements LoginService{

    @Autowired
    private LoginDao loginDao;

    @Override
    public Map loginSelect(@Param("username") String username, @Param("password") String password) {
        boolean loginOK;
        List<Account> accountList = loginDao.loginSelect(username,password);
        HashMap map = new HashMap();
        // 将查询到的用户和一个loginOK的值封装到HashMap中
        if (accountList == null || accountList.isEmpty()) {
            System.out.println("==============用户查询失败=============");
            loginOK = false;
        } else {
            System.out.println("==============用户查询成功=============");
            map.put("accountList",accountList);
            loginOK = true;
        }
        map.put("loginOK",loginOK);
        return map;
    }

}
